const validatePhone = (rule, value, callback) => {
  if (!/^[1]([3-9])[0-9]{9}$/.test(value)) {
    callback(new Error('请输入正确的手机号格式'))
  } else {
    callback()
  }
}
const validateEmail = (rule, value, callback) => {
  if (!/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(value)) {
    callback(new Error('请输入正确的邮件格式'))
  } else {
    callback()
  }
}
export const contactOption = function () {
  return {
    refreshBtn: true,
    columnBtn: true,
    border: true,
    stripe: true,
    index: true,
    editBtn: true,
    delBtn: false,
    align: 'center',
    addBtn: !['view'].includes(this.type),
    menu: !['view'].includes(this.type),
    indexLabel: '序号',
    column: [
      {
        label: '姓名',
        prop: 'contactName',
        slot: this.slotFlg,
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入姓名',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '性别',
        prop: 'sex',
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入性别',
            trigger: 'blur'
          }
        ],
        slot: this.slotFlg,
      },
      {
        label: '部门',
        prop: 'dept',
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入部门',
            trigger: 'blur'
          }
        ],
        slot: this.slotFlg,
      },
      {
        label: '职务',
        prop: 'post',
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入职务',
            trigger: 'blur'
          }
        ],
        slot: this.slotFlg,
      },
      {
        label: '手机号码',
        prop: 'phone',
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入手机号码',
            trigger: 'blur'
          },
          { validator: validatePhone, trigger: 'blur' }
        ],
        slot: this.slotFlg,
      },
      {
        label: '邮箱',
        prop: 'email',
        maxlength: 50,
        rules: [
          {
            required: true,
            message: '请输入邮箱',
            trigger: 'blur'
          },
          { validator: validateEmail, trigger: 'blur' }
        ],
        slot: this.slotFlg,
      },

      {
        label: '固定电话',
        prop: 'telephone',
        maxlength: 50,
        slot: this.slotFlg,
      }
    ]
  }
}
export const staffOption = function () {
  return {
    refreshBtn: true,
    columnBtn: true,
    border: true,
    stripe: true,
    index: true,
    editBtn: true,
    delBtn: true,
    align: 'center',
    addBtn: !['view'].includes(this.type),
    menu: !['view'].includes(this.type),
    indexLabel: '序号',
    column: [
      {
        label: '人员类型',
        labelWidth: 100,
        span: 12,
        prop: 'personnelType',
        type: 'select',
        dicUrl: '/api/blade-system/dict-biz/dictionary?code=user_type',
        props: {
          label: 'dictValue',
          value: 'dictKey'
        },
        rules: [
          {
            required: true,
            message: '请输入人员类型',
            trigger: 'change'
          }
        ],
        slot: this.slotFlg
      },
      {
        label: '总人数',
        prop: 'totalPeople',
        maxlength: 20,
        span: 12,
        rules: [
          {
            required: true,
            message: '请输入总人数',
            trigger: 'blur'
          }
        ],
        slot: this.slotFlg
      },
      {
        label: '平均工作年限',
        prop: 'avgWorkingYears',
        labelWidth: 120,
        maxlength: 20,
        span: 12,
        slot: this.slotFlg
      }
    ]
  }
}
